.PHONY: help dep upgrade fmt lint

.DEFAULT_GOAL := help

help: ## Display this help screen.
	@echo "Makefile available targets:"
	@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  * \033[36m%-15s\033[0m %s\n", $$1, $$2}'

dep: ## Fix dependencies.
	go mod tidy

upgrade: ## Upgrade all dependencies.
	go get -d -u ./... 

generate: ## Generate code.
	go generate ./...

fmt: ## Format code.
	goimports -w .
	gofumpt -l -w -extra .

lint: ## Check code.
	golangci-lint run ./... --disable-all --timeout=5m --color always --verbose\
                  -E revive,govet,misspell,staticcheck,errcheck,gocritic,goconst,unused,unconvert,unparam,ineffassign,\
prealloc,exportloopref,dupl,gosimple,gci,typecheck,stylecheck,bodyclose,containedctx,contextcheck,gocyclo,errorlint,nilerr,perfsprint,sloglint

test: ## Run test.
	go test ./...

bench: ## Run benchmark.
	go test -bench=. -benchmem ./...
